package com.pengchuang.ACS.gateway.config.kaptcha;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RequestPredicates;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

@Configuration
public class CaptchaRouter {

    @Bean
    public RouterFunction<ServerResponse> routerFunction(CaptchaHandler captchaHandler) {
        return RouterFunctions
                .route(RequestPredicates.GET("/api/captcha")
                        .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)),
                        captchaHandler::handle);
    }

}
